package com.beadwallet.alarm.util;

import com.alibaba.fastjson.JSONObject;
import com.beadwallet.alarm.config.WeChatParames;
import com.beadwallet.common.enums.CodeEnum;
import org.apache.commons.lang.StringUtils;

/**
 * 对返回的结果进行校验工具类
 *
 * @author hyf
 */
public class CheckResultUtil {

    public static String checkWeChatResult(JSONObject json) {
        if (json.getInteger(WeChatParames.ERRCODE) == WeChatParames.SAFE_0) {
           if (StringUtils.isBlank(json.getString(WeChatParames.INVALIDUSER)) & StringUtils.isNotBlank(json.getString(WeChatParames.INVALIDPARTY))) {
                return CodeEnum.FAILURE.getCode();
                //StringUtils.isNotBlank()
            } else if (StringUtils.isBlank(json.getString(WeChatParames.INVALIDPARTY)) & StringUtils.isBlank(json.getString(WeChatParames.INVALIDUSER))) {
                return CodeEnum.SUCC.getCode();
            } else {
                return CodeEnum.FAILURE.getCode();
            }
        } else {
            return CodeEnum.FAILURE.getCode();
        }
    }
}
